<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:useBean id="db" class="ctm.javacode.DbBean"/>
<jsp:useBean id="Pagination" class="ctm.javacode.Pagination"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>中醫問卷養生系統</title>

<style type="text/css">
<!--
body {
	background-image: url(img/grass.jpg);
    background-position: center top;
	background-color: #FFFFFF;
	background-repeat: repeat;
}
body,td,th {
	color: #000000;
	font-size:24px;
	font-family: Arial;
}


a:link {
font-family:"標楷體"; 
	font-size:25px;
	text-decoration:none;
	color: #1B4001;
	background-color:#FFFFFF;
}
a:visited {
	font-family:"標楷體"; 
	font-size:25px;
	text-decoration:none;
	color:#1B4001;
	background-color:#FFFFFF;
}
a:hover {
font-family:"標楷體"; 
	font-size:25px;
	text-decoration:none;
	color:#000000;
	background-color:#FFFFFF;
}


.ind:link {
color: #535353;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}
.ind:visited {
color:#535353;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}

.ind:hover {
color:#BB280F;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}

.HEAD_STYLE {
	font-weight:bold;
	color: #1B4001;
	font-family:"標楷體";
	font-size:30px; 
}
.TEXT_STYLE {
	font-family:Arial;
	color:#193940;
	font-size:24px;
	font-weight:bold;
}
.BOTTOM_STYLE {
	color: #FFFFFF; 
	font-family: Arial; 
	font-size:20px;
}
.LEFT_BUTTON {
	font-family:"標楷體"; 
	font-size:30px;
}

-->
</style>

</head>
<body alink="#FF0000" vlink="#FF0000">
<%
    int curPages = Pagination.curPages(Pagination.strPage(request,"page")); //Pagination.strPage(request,"page")取page值傳遞給curPages()方法
    Pagination.setRows(10); //設置每頁顯示10條
    int totalPage = 1 ;
%>
<%
    db.setDataSource("jdbc/questionHistory");
	if ( db.isConnectedOK() ) {
		String name = (String)request.getSession().getAttribute("login");
		String filename ="";
		String category ="";
		String sqlQuery = "select Questionnaire, filename from qARm where managerName = '" +
								request.getSession().getAttribute("login") + "'order by id desc";	 
		ResultSet rs;
		rs = db.ExcuteResult(sqlQuery);	
	    rs.last();
		int resultCount = rs.getRow() ;
		rs.first();
	    totalPage = Pagination.getPages(resultCount);	
		ResultSet rsTen = Pagination.getPageSet(rs, curPages);
		
		%>
<table width="100%" border="0">
		<tr>
			<td><p>&nbsp;</p></td>
		</tr>
				
			
			
		
 
    		<td width="5%">&nbsp;</td>
			
			<td bgcolor="#FFFFFF"><table width="100%" border="0">
      			<tr>
        			<td background="img/herbal.jpg">
						<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
		  				<p>&nbsp;</p>
          
          			</td>
			  </tr>
     
	 
	 
	 
	  			  <tr>
        			<td>	
						<table bgcolor="#437A27" width="100%" border="0">
         					 <tr>
            					<td>&nbsp;</td>
           			 			
          			 		</tr>
        				</table>
					</td>
     			  </tr>
      
	  			
	  
	  
	  
	 			  <tr>
        				<td>
							<table width="100%">
           						<tr>
									<td valign="top">
										<table width="100%">
											
											<tr>
												<td class="HEAD_STYLE" align="center">使用者歷史問卷</td>
													
											</tr>
											
											<tr>
												<td >
												 	<table border="1" align="center" width="50%">
											  	<tr>
	    
	    										<td class="TEXT_STYLE" align="center">歷史問卷</td>
	   											 <td class="TEXT_STYLE" align="center">問卷類別</td>
												 <td class="TEXT_STYLE" align="center">前往觀看</td>
	  										   </tr>
											
												  <%int i=1;%>
	   											 <%while (rsTen.next()){%>
	 										   <tr>
											    <td align="center"><%=filename = rsTen.getString("filename")%></td>
											    <td align="center"><%=category = rsTen.getString("Questionnaire")%></td>
								<td align="center"><a href="history.jsp?=filename=<%=filename%>&category=<%=category%>">Go</a></td>
	  <%
	    i=i+1;
	    if(i>10)
	        break;
	    }
	    %>
												 
											 </table>
	    <% 
	} // end if
	else {
		out.println( "DataBase Error" );
	} // end else
%>
<p align="center">
<%if(curPages>1){%>
<a href="listhistory.jsp?page=<%=curPages-1%>">上一頁</a>
<%}%>
<%if(curPages<totalPage){%>
<a href="listhistory.jsp?page=<%=curPages+1%>">下一頁</a>
<%}%></p>
												</td>
													
											</tr>
											
											<tr>
												<td align="center"> <button onClick="location='main.jsp'">返回主選單</button></td>
											</tr>
										</table>
									
             

		
											
								  </td>
									

								</tr>
       					 </table>
         

         				</td>
			  </tr>
   
	  
					 <tr>
      					  
   					    <td><p>&nbsp;</p></td>
  					 </tr>
	  				
					<tr>
      					  <td bgcolor="#437A27"><div align="center" class="BOTTOM_STYLE">Copyright@CCU_PLlab</div></td>
   
			  </tr>
    						
  	 			  
	
			</table>
		</td>
	    
		<td width="5%">&nbsp;</td>
</table>
<p>&nbsp;</p>
</body>
</html>
